90B - African Crossword - CodeForces Solution


implementation strings *1100

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
#define ll long long
#define w "YES\n"
#define n "NO\n"
#define en endl
#define agaarki if
#define tovaqteki for
#define qq long long q; cin>>q; for(int i=0;i<q;i++)
#define fx fixed<<setprecision(9)
#define iqBoost ios_base::sync_with_stdio(false), cin.tie(0);
using namespace std;
main()
{
    //B. ����������� ���������
    string s;
    int a,b;
    cin>>a>>b;
    char ar[a][b];
    for(int i=0; i<a; i++)
        for(int j=0; j<b; j++)
            cin>>ar[i][j];
    for(int i=0; i<a; i++)
        for(int j=0; j<b; j++)
        {
            int g=0;
            for(int x=1; x<=max(a,b); x++)
            {
                if(i+x<a and ar[i][j]==ar[i+x][j])
                    g++;
                if(j+x<b and ar[i][j]==ar[i][j+x])
                    g++;
                if( i-x>=0 and ar[i][j]==ar[i-x][j])
                    g++;
                if(j-x>=0 and ar[i][j]==ar[i][j-x])
                    g++;
            }
            if(g==0)
                s+=ar[i][j];
        }
    cout<<s;


}
/**
{
    //A. ����������������� ������������ ���������������������
    string s;
    cin>>s;
    string g=s;
    sort(g.rbegin(),g.rend());
    string d;
    int pos=0;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]==g[pos] || i==s.size()-1)
        {
            d+=s[i];
            pos++;
        }
    }
    cout<<d;
}
/**
abbcbccacbbcbaaba
cccccbbbbbbbaaaaa
{
    //B. ���������� ����
    string s,s1;
    cin>>s;
    char c='a';
    for(int i=0;i<s.size();i++)
    {
        if(s1.find(s[i])==-1 )
        {
            if(c==s[i]){
            c=char(c+1);
            s1+=s[i];
            }
            else
                return cout<<"NO",0;
        }
    }
    cout<<"YES";
}
/**
 /////A. ������� ������� ������
bool is_palindrom(string s)
{
    for(int l=0,r=s.size()-1;l<s.size();l++,r--)
    {
        if(s[l]!=s[r])
            return false;
    }
    return true;
}
main()
{
    string s,s1;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s1.find(s[i])==-1)
            s1+=s[i];
    }
    for(int h=0;h<s1.size();h++)
    for(int i=0;i<s.size();i++)
    {
        string m;
        for(int j=0;j<i;j++)
            m+=s[j];
        m+=s1[h];
        for(int j=i;j<s.size();j++)
            m+=s[j];
        if(is_palindrom(m)==true)
            return cout<<m,0;
    }
    for(int h=0;h<s1.size();h++)
    {
        string i=s+s1[h];
                if(is_palindrom(i)==true)
            return cout<<i,0;
    }
    cout<<"NA";
}
/**
{
    //B. ��������-�����
    string s;
    cin>>s;
    if(s[0]=='h'){
        cout<<"http://";
        s.erase(s.begin()+0);
        s.erase(s.begin()+0);
        s.erase(s.begin()+0);
        s.erase(s.begin()+0);}
    else
    {
        cout<<"ftp://";
        s.erase(s.begin()+0);
        s.erase(s.begin()+0);
        s.erase(s.begin()+0);
    }
    int p=-1;
    for(int i=0;i<s.size()-1;i++)
    {
        if(s[i]=='r' and s[i+1]=='u')
            p=i;
    }
    for(int i=0;i<p;i++)
        cout<<s[i];
    cout<<".ru";
    if(p!=s.size()-2)
    {
        cout<<'/';
        for(int i=p+2;i<s.size();i++)
            cout<<s[i];
    }

}

/**
asdasd
012345
10
6 9 4 7 8 2 3 5 0 1
 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

I will succes !

freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);


         **--------------------**
           RESHETOI AKAI MUSLIM
    vector < bool >prime(N, true);
    for(ll i = 2; i <= 1000000; i ++) {
        if(!prime[i]) {
            continue;
        }
        for(ll j = i * i; j <= 1000000; j += i) {
            prime[j] = false;
        }
    }
B.Shahrom
k.ibrohim
Z.muhammad
k.ismoil
---ME---
**/


Comments

Submit
0 Comments
More Questions

1180A - Alex and a Rhombus
445A - DZY Loves Chessboard
1372A - Omkar and Completion
159D - Palindrome pairs
981B - Businessmen Problems
1668A - Direction Change
1667B - Optimal Partition
1668B - Social Distance
88B - Keyboard
580B - Kefa and Company
960A - Check the string
1220A - Cards
897A - Scarborough Fair
1433B - Yet Another Bookshelf
1283B - Candies Division
1451B - Non-Substring Subsequence
1408B - Arrays Sum
1430A - Number of Apartments
1475A - Odd Divisor
1454B - Unique Bid Auction
978C - Letters
501B - Misha and Changing Handles
1496A - Split it
1666L - Labyrinth
1294B - Collecting Packages
1642B - Power Walking
1424M - Ancient Language
600C - Make Palindrome
1669D - Colorful Stamp
1669B - Triple